<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>修改密码 - {:config('web.WEB_TIT')}</title>
	{include file="member/public"}
</head>
<body>
	<header data-am-widget="header" class="am-header am-header-default jz">
		<div class="am-header-left am-header-nav">
			<a href="javascript:history.back()" class="">
				<i class="am-icon-chevron-left"></i>
			</a>
		</div>
		<h1 class="am-header-title">
			<a href="#title-link" class="">修改密码</a>
		</h1>
	</header>
	<ul class="nav maa" style="margin-top: 10px;">
		<li>
			<span>原密码</span>
			<input type="password" name="pass" id="pass" value="" placeholder="请在此输入原密码"/>
		</li>
		<li>
			<span>新密码</span>
			<input type="password" name="new_pass" id="new_pass" value="" placeholder="请在此输入新密码"/>
		</li>
		<li>
			<span>确认新密码</span>
			<input type="hidden" name="__token__" id="token" value="{$Request.token}" />
			<input type="password" name="re_new_pass" id="re_new_pass" value="" placeholder="请再次输入新密码"/>
		</li>
	</ul>
	<div class="shure" id="submit">
		<a href="">确认提交</a>
	</div>
	<script type="text/javascript">
        $('#submit').click(function(){
            var pass = $('#pass').val();
            var new_pass = $('#new_pass').val();
            var re_new_pass = $('#re_new_pass').val();

            if(pass == ''){
                alert('原密码不能为空');
                return false;
            }
            if(new_pass == ''){
                alert('新密码不能为空');
                return false;
            }
            if(new_pass != re_new_pass){
                alert('新密码不一致');
                return false;
			}

            $.ajax({
                type: 'POST',
                url : "{:url('member/set_password')}",
                data:{
                    pass:pass,
                    new_pass:new_pass,
                    re_new_pass:re_new_pass,
                    token:$('#token').val()
                },
                dataType:'json',
                success: function(data){
                    if(data.code == 200){
                        alert(data.msg)
                        window.location.href = "{:url('member/set')}";
                    }else{
                        alert(data.msg);
                        location.reload(true);
                    }
                },
            });
        });
	</script>
</body>
</html>
